<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  // let arr = [1, 2, 3]
  // let a = arr[0]
  // let b = arr[1]
  // let c = arr[2]
  // 机构一一对应
  let [a, b, c] = [1, 2, 3]
  console.log(a, b, c)

  let [m, n, [i, j]] = [1, 2, [3, 4]]
  console.log(m, n, i, j)

  //忽略某个元素 ,隔开
  let [name1, , name2] = ["李唯一", "姜宁", "左丘红婷"]
  console.log(name1, name2)

  // 变量的交换
  let str1 = "apple";
  let str2 = "pear";

  [str1, str2] = [str2, str1]
  console.log(str1, str2)

  // 剩余/扩展运算符
  // 剩余运算符
  let [name, ...reset] = ['张若尘', '黄烟尘', '木灵希', '洛姬']
  console.log(name, reset)

  // 扩展运算符
  let res = ['罗乷', '纪梵心']

  let arr3 = ["白卿儿", "无月", ...res, ...reset]
  console.log(arr3)
</script>

</html>